package com.qxy.practice.concurrent;

/**
 * @author : 戚欣扬
 * @code :8锁问题
 */
class Phone{
    public  synchronized  void email() throws InterruptedException {
        Thread.sleep(1000);
        System.out.println("email = 666@" );
        Thread.sleep(1000);
    }

    public   void sms() throws InterruptedException {
        Thread.sleep(1000);
        System.out.println("sms = 222" );
        Thread.sleep(1000);
    }
}

public class EghitLock {

    public static void main(String[] args) {
        Phone phone = new Phone();
        new Thread(()->{
            try {
                phone.email();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        },"A").start();

        new Thread(()->{
            try {
                phone.sms();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        },"B").start();
    }
}


